package com.vip.base.config;

import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;

import javax.annotation.Resource;

public class MyRealm extends AuthorizingRealm {

//    @Resource
//    private UserService userService;

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
        return null;
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        String username = (String)authenticationToken.getPrincipal();
        String password = String.valueOf((char[])authenticationToken.getCredentials());
//        User user = userService.findByUsername(username);
//        if(null==user){
//            throw new UnknownAccountException("账号不存在");
//        }
//        String salt = user.getSalt();
//        String findPassword = user.getPassword();
//        return new SimpleAuthenticationInfo(user,findPassword, ByteSource.Util.bytes(salt),getName());
        return null;
    }

}
